/*
 * @Author: lusx
 * @Date: 2019-02-18 13:41:35
 * @Last modified by:   lusx
 * @Last modified time: 07-03-2019 10:04:25
 */

import {WeaTop,WeaNewScroll,WeaLocaleProvider,WeaTab,WeaInputSearch} from 'ecCom';
import {toJS} from 'mobx';
const getLabel = WeaLocaleProvider.getLabel;

//嵌套WeaTop顶部组件
const WeaTopHoc = (WrappedComponent) =>
 class extends React.Component {
   render() {
     const {type,loading,pies,doSearch,searchsBaseValue,selectedKey,switchTab} = this.props;
     const ctrlHeight = document.body.clientHeight - 128-47;
     let scrollWidth = document.body.clientWidth - 395;
     const title = {
       "0" : getLabel('500438',"整体监控"),
       "1" : getLabel('500439',"承办统计"),
       "2" : getLabel('500440',"类别统计"),
       "3" : getLabel('386394',"状态统计"),
     };
     const needScroll = type === "1" ? true : false;
     return (
       <div className='g-weaTopHoc'>
          <WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@kudg0r`}
           title={<span>{title[type]}</span>}
           icon={<i className='icon-coms-government' />}
           iconBgcolor='#f14a2d'
           loading = {loading}
          />
          {
              type !== "0" ?
              pies.length === 1 ?
              <div style={{height:'46px',lineHeight:'46px',marginRight:'10px',float:'right'}}>
              <WeaInputSearch ecId={`${this && this.props && this.props.ecId || ''}_WeaInputSearch@fkwqq7`}
              onSearch={v=>{doSearch(v)}}
              value = {searchsBaseValue}
              /></div> :
              <WeaTab ecId={`${this && this.props && this.props.ecId || ''}_WeaTab@egoull`}
              leftStyle={{width:`${scrollWidth}px`}}
              searchType={['base']}
              searchsBaseValue={searchsBaseValue}
              datas={"1".includes(type) ? toJS(pies) : []}
              selectedKey={selectedKey}
              onSearch={v=>{doSearch(v)}}
              keyParam="key"
              countParam="groupid"
              onChange={switchTab}
              /> : null
           }
           {
             needScroll === true ? <WrappedComponent ecId={`${this && this.props && this.props.ecId || ''}_WrappedComponent@3cqvx5`} {...this.props} /> : (<WeaNewScroll ecId={`${this && this.props && this.props.ecId || ''}_WeaNewScroll@1h5c2a`} height={ctrlHeight} >
               <WrappedComponent ecId={`${this && this.props && this.props.ecId || ''}_WrappedComponent@i2189t`} {...this.props} />
             </WeaNewScroll>)
           }

       </div>
     )
   }

 }
 export default WeaTopHoc;
